package cn.edu.tju.elm.model;

/**
 * 交易类型枚举
 */
public enum TransactionType {
    /**
     * 充值
     */
    RECHARGE("RECHARGE", "充值"),
    
    /**
     * 充值返点
     */
    RECHARGE_BONUS("RECHARGE_BONUS", "充值返点"),
    
    /**
     * 提现
     */
    WITHDRAW("WITHDRAW", "提现"),
    
    /**
     * 提现手续费
     */
    WITHDRAW_FEE("WITHDRAW_FEE", "提现手续费"),
    
    /**
     * 转账支付（支出）
     */
    TRANSFER_OUT("TRANSFER_OUT", "转账支出"),
    
    /**
     * 转账收款（收入）
     */
    TRANSFER_IN("TRANSFER_IN", "转账收入"),
    
    /**
     * 冻结
     */
    FREEZE("FREEZE", "冻结"),
    
    /**
     * 解冻
     */
    UNFREEZE("UNFREEZE", "解冻"),
    
    /**
     * 透支
     */
    OVERDRAFT("OVERDRAFT", "透支"),
    
    /**
     * 还款
     */
    REPAYMENT("REPAYMENT", "还款"),
    
    /**
     * 利息支付
     */
    INTEREST("INTEREST", "利息"),
    
    /**
     * 退款
     */
    REFUND("REFUND", "退款");

    private final String code;
    private final String description;

    TransactionType(String code, String description) {
        this.code = code;
        this.description = description;
    }

    public String getCode() {
        return code;
    }

    public String getDescription() {
        return description;
    }

    public static TransactionType fromCode(String code) {
        for (TransactionType type : values()) {
            if (type.code.equals(code)) {
                return type;
            }
        }
        throw new IllegalArgumentException("Unknown transaction type: " + code);
    }
}

